﻿using System;
using System.Windows.Forms;
using ApplicationGenerator.BusinessModule.MetaElements;

namespace GUserInterface
{
    public partial class NewFormDlg : Form
    {

        #region Variables

        int rows;
        int cols;
        string title;
        string _sourceName;

        #endregion

        #region Construction

        public NewFormDlg(string title)
        {
            InitializeComponent();
            InitializeComponent_Custom(title);
        }

        private void InitializeComponent_Custom(string title)
        {
            textBox1.Text = title;
        }

        #endregion

        #region Methods

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != string.Empty)
            {
                rows = (int)numericUpDown1.Value;
                cols = (int)numericUpDown2.Value;
                title = textBox1.Text;
                _sourceName = comboBox1.Items[comboBox1.SelectedIndex].ToString();
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                this.DialogResult = DialogResult.Abort;
            }
        }

        #endregion

        #region Properties

        public int NumOfRows
        {
            get { return rows; }
        }

        public int NumOfCols
        {
            get { return cols; }
        }

        public string Title
        {
            get { return title; }
        }

        public string SourceName
        {
            get { return _sourceName; }
        }

        #endregion

        private void NewFormDlg_Load(object sender, EventArgs e)
        {
            foreach (string name in MetaModelManager.Instance.MetaModelCollection.GetMetaModelNames())
            {
                comboBox1.Items.Add(name);
            }

            comboBox1.SelectedIndex = 0;
        }

    }
}
